﻿/*
 * 绘制血压检查的报告单
 * */
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WH.NurseSys.Model;

namespace WH.NurseSys.BLL.Report
{
    public class DrawReportBloodPressure:DrawReport
    {
        //绘制整个报告
        public void DrawReport(Graphics dc, Patient patient, List<BloodPressure> bloodPressureList, string reportTitle, float hardMarginX, float hardMarginY)
        {
            dc.PageUnit = GraphicsUnit.Document;
            dc.TranslateTransform(hardMarginX * 3, hardMarginY * 3);
            dc.Clear(Color.White);
            drawInfo(dc, patient, reportTitle);
            drawData(dc, bloodPressureList);
        }

        //绘制血压测量数据
        private void drawData(Graphics dc, List<BloodPressure> bloodPressureList)
        {
            float x11 = 15 * dotPerMm;
            float x12 = (15 + 17) * dotPerMm;
            float x13 = (15 + 34) * dotPerMm;
            float x14 = (15 + 50) * dotPerMm;
            float x21 = 105 * dotPerMm;
            float x22 = (105 + 17) * dotPerMm;
            float x23 = (105 + 34) * dotPerMm;
            float x24 = (105 + 50) * dotPerMm;
            float yTop = (15 + 28) * dotPerMm;
            float yBottom = (297 - 15) * dotPerMm;
            Font textFont = new Font("宋体", 14, FontStyle.Regular, GraphicsUnit.Point);
            dc.DrawString("收缩压", textFont, Brushes.Black, x11, yTop);
            dc.DrawString("舒张压", textFont, Brushes.Black, x12, yTop);
            dc.DrawString("脉搏", textFont, Brushes.Black, x13, yTop);
            dc.DrawString("时间", textFont, Brushes.Black, x14, yTop);
            dc.DrawString("收缩压", textFont, Brushes.Black, x21, yTop);
            dc.DrawString("舒张压", textFont, Brushes.Black, x22, yTop);
            dc.DrawString("脉搏", textFont, Brushes.Black, x23, yTop);
            dc.DrawString("时间", textFont, Brushes.Black, x24, yTop);
            int columnCount = (int)(((297 - 15) * dotPerMm - yTop) / textFont.GetHeight(dc));
            float yCurrent = yTop + textFont.GetHeight(dc);
            for (int i = 0; i < bloodPressureList.Count; i++)
            {
                if (i <= columnCount)
                {
                    dc.DrawString(bloodPressureList[i].Sys.ToString(), textFont, Brushes.Black, x11, yCurrent);
                    dc.DrawString(bloodPressureList[i].Dia.ToString(), textFont, Brushes.Black, x12, yCurrent);
                    dc.DrawString(bloodPressureList[i].Pulse.ToString(), textFont, Brushes.Black, x13, yCurrent);
                    dc.DrawString(bloodPressureList[i].ExecTime.ToString("yy-MM-dd HH:mm"), textFont, Brushes.Black, x14, yCurrent);
                    yCurrent += textFont.GetHeight(dc);
                    if(i==columnCount)
                        yCurrent = yTop + textFont.GetHeight(dc);
                }
                else
                {
                    dc.DrawString(bloodPressureList[i].Sys.ToString(), textFont, Brushes.Black, x21, yCurrent);
                    dc.DrawString(bloodPressureList[i].Dia.ToString(), textFont, Brushes.Black, x22, yCurrent);
                    dc.DrawString(bloodPressureList[i].Pulse.ToString(), textFont, Brushes.Black, x23, yCurrent);
                    dc.DrawString(bloodPressureList[i].ExecTime.ToString("yy-MM-dd HH:mm"), textFont, Brushes.Black, x24, yCurrent);
                    yCurrent += textFont.GetHeight(dc);
                }
            }
            textFont.Dispose();
        }
    }
}
